<style>
.layui-input-block{
margin-left:120px;
}
</style>
<form class="layui-form" action="" id="orderEditForm" style="position: absolute;">
<div class="layui-row"  style="margin-top:10px;">
	  <input type="hidden" name="id" class="layui-input" lay-verify="required" th:value="${obj.id}"/>
	 <div class="layui-form-item">
		    <label class="layui-form-label" style="width:120px;">旧密码</label>
		    <div class="layui-input-block" style="width:200px;">
		         <input type="password" name="opwd" placeholder="请输旧密码"class="layui-input" lay-verify="required"/>
		    </div>
	   </div>

  	 
	  <div class="layui-form-item">
		    <label class="layui-form-label" style="width:120px;">新密码</label>
		    <div class="layui-input-block" style="width:200px;">
				 <input type="password" id="npd" name="npd" placeholder="请输入新密码" class="layui-input" lay-verify="required"/>
		    </div>
	   </div>
  	
	  <div class="layui-form-item">
	    <label class="layui-form-label" style="width:120px;" >新密码确认</label>
	    <div class="layui-input-block" style="width:200px;">
		     <input type="password" name="npda" id="npda" placeholder="请输入新密码" class="layui-input" lay-verify="required"/>
	    </div>
	   </div>
</div>
  
 <div class="layui-row" style="margin-top:20px;">
    <div class="layui-col-xs12 layui-col-sm12 layui-col-md12" style="text-align:center;margin-left:30px;">
          <button class="layui-btn" lay-submit="" lay-filter="formSubmit" authcode="900340">提交</button>
      	<button type="button" class="layui-btn layui-btn-primary" id="closeBtn">关闭</button>
    </div>
  </div>
</form>

<script>

//start use
layui.use('form', function(){
	
	  var form = layui.form; //只有执行了这一步，部分表单元素才会自动修饰成功
	  //……
	  //但是，如果你的HTML是动态生成的，自动渲染就会失效
	  //因此你需要在相应的地方，执行下述方法来手动渲染，跟这类似的还有 element.init();
	  form.render();
	  
	  var submit=false;
		$("#npda").blur(function(){
			if($("#npda").val() == $("#npd").val()){
				submit=true;
			}else{
				layer.msg("两次密码不一致！");
				return false;
			}
			
		});
	  
	//监听表单提交
	form.on('submit(formSubmit)',function(data) {
		if(!submit){
  			layer.msg("两次密码不一致！");
  			return false;
  		}
		$.ajax({url:'/sys/user/pwd',
			data:$("#orderEditForm").serializeJson(),
			type:"get",
			contentType:"application/json",
			success:function(data){
				if(data.code==200){
					layer.msg("数据保存成功！");
					layer.closeAll();
				}else{
					layer.msg(data.message);
				}
			}});
		return false;
	});
	$('#closeBtn').click(function() {
		layer.close(editdialogindex);
	});
});
//end use
</script>